function getUrlParam(key: string) {
    if (typeof window === 'undefined' || window === null) {
        return;
    }

    if ((window.location.search?.toString()?.trim()?.length ?? -1) <= 0) {
        return;
    }

    const reg = new RegExp(`[\?|&]?${key}=([^&]+)&?`, 'i');
    const matchResult = window.location.search.match(reg);

    return matchResult?.[1];
}

export { getUrlParam };
